Hi,
I have this code: Module myCurrentModule //Nur das erste Modul aus der Skip-Liste auslesen, damit die Iteration gestartet werden kann.
if(find(mySkipList, 1, myCurrentModuleSkip)) { if(read(fullName(myCurrentModuleSkip)) == Module) { myCurrentModule = read(fullName(myCurrentModuleSkip)) } else { print "Kein Modul!" } }
My question now is: How can I check if a module is in "myCurrentModuleSkip"? I will check this in the second if-statement. tobi_mehrl - Mon Jun 01 04:31:13 EDT 2015 |
Re: Read content of a skip list Hi // you want to check if the module exists in the skip bool
hasModuleInList(Skip skpWork, string sModuleID) {
Module mdlWork;
for mdlWork in skpWork do {
if (uniqueID(mdlWork) == sModuleID) { return(true) } }
return(false); }
// you want to get the module Module
getModuleFromList(Skip skpWork, string sModuleID) {
Module mdlWork;
for mdlWork in skpWork do {
if (uniqueID(mdlWork) == sModuleID) { return(mdlWork) } }
return(null); } |
Re: Read content of a skip list Wolfgang Uhr - Mon Jun 01 05:18:35 EDT 2015 Hi // you want to check if the module exists in the skip bool
hasModuleInList(Skip skpWork, string sModuleID) {
Module mdlWork;
for mdlWork in skpWork do {
if (uniqueID(mdlWork) == sModuleID) { return(true) } }
return(false); }
// you want to get the module Module
getModuleFromList(Skip skpWork, string sModuleID) {
Module mdlWork;
for mdlWork in skpWork do {
if (uniqueID(mdlWork) == sModuleID) { return(mdlWork) } }
return(null); } Wonderfull, IBM has changed a bad forum to a worst. |
Re: Read content of a skip list Hi Wolfgang, sorry, but was I mean is, that I don't want to check If a specific module is in the skip list. What I want to do is, that I will check, if the first element of the skip list is from type "module". Do you understand what I mean? What you in your code do is to test, if in the skip is a module which a specific name; which specific name is assigned in sModuleID, I think. |
Re: Read content of a skip list tobi_mehrl - Mon Jun 01 05:40:28 EDT 2015 Hi Wolfgang, sorry, but was I mean is, that I don't want to check If a specific module is in the skip list. What I want to do is, that I will check, if the first element of the skip list is from type "module". Do you understand what I mean? What you in your code do is to test, if in the skip is a module which a specific name; which specific name is assigned in sModuleID, I think. Hi Tobi If you want to find the first entry, create a skip loop inside a function and return using the first hit from the loop. But if you want to find out of the first entry is a module or an object, forget it. DXL will provide the datatype unless a crash - not an error but a real crash occurs. And of course, thats the thing, type casting has been made for. You have to know the datatye you are dealing with. Best regards Wolfgang |
Re: Read content of a skip list quote: "And of course, thats the thing, type casting has been made for."
What do you mean by saying this? |
Re: Read content of a skip list tobi_mehrl - Mon Jun 01 06:37:25 EDT 2015 quote: "And of course, thats the thing, type casting has been made for."
What do you mean by saying this? You have to know the datatype you are dealing with. |
Re: Read content of a skip list tobi_mehrl - Mon Jun 01 06:37:25 EDT 2015 quote: "And of course, thats the thing, type casting has been made for."
What do you mean by saying this? It means you need to know what type is in the Skip BEFORE you try to pull it out. If it is indeed an Object and you put it into a Module handle you can expect quick destruction of your run time environment the first time you use that Module handle. I suggest you are making a big conceptual mistake in your script design if you NEED to put both Objects and Modules into the same Skip, with an "int" sequencer KEY. But you may have your cake and eat it too if you cleverly decide that all "Module" handles in the Skip have an odd 'int' Key; whereas all "Object" handles have an even 'int' Key.
-Louie |
Re: Read content of a skip list llandale - Mon Jun 01 19:35:06 EDT 2015 It means you need to know what type is in the Skip BEFORE you try to pull it out. If it is indeed an Object and you put it into a Module handle you can expect quick destruction of your run time environment the first time you use that Module handle. I suggest you are making a big conceptual mistake in your script design if you NEED to put both Objects and Modules into the same Skip, with an "int" sequencer KEY. But you may have your cake and eat it too if you cleverly decide that all "Module" handles in the Skip have an odd 'int' Key; whereas all "Object" handles have an even 'int' Key.
-Louie ( Have you tried to indicate the type when you add data in the skip ... Here a simple example with string and int ... but you can use the types you need to ;) [code] DxlObject obj
// skip list with integer as key, dxl object as data Skip test = create()
obj = new() put(test, 1, obj)
obj = new() put(test, 2, obj)
// get data with the proper type - 0.0
for obj in test do { // get data - version 0.1
int tmp_integer = null
string getdata(DxlObject obj) {
int getdata(DxlObject obj) {
for obj in test do {
// clean memory [/code] |
Re: Read content of a skip list pommCannelle - Mon Jun 22 08:40:39 EDT 2015 ( Have you tried to indicate the type when you add data in the skip ... Here a simple example with string and int ... but you can use the types you need to ;) [code] DxlObject obj
// skip list with integer as key, dxl object as data Skip test = create()
obj = new() put(test, 1, obj)
obj = new() put(test, 2, obj)
// get data with the proper type - 0.0
for obj in test do { // get data - version 0.1
int tmp_integer = null
string getdata(DxlObject obj) {
int getdata(DxlObject obj) {
for obj in test do {
// clean memory [/code] > Have you tried to indicate the type when you add data in the skip ... Here a simple example with string and int ... but you can use the types you need to It is much more simple to use a prefix in the variable. int iSomeInt = 12: string sSomeString = "some words" Object objSomeObject = ... put(mySkip, "iSomeInt ", iSomeInt); put(mySkip, "sSomeString", sSomeString); put(mySkip, "objSomeObject", objSomeObject); If your loop runs through that list, your prefix will tell you the type. Best regards Wolfgang
|